﻿
using System;
using System.Collections.Generic;
using System.Data;
namespace AssettDatabase.BLL
{
    class Vendor
    {
        public bool Add(string Vendor_Name, string Vendor_Support_Phone, string Vendor_Support_Email, string Vendor_Notes)
        {
            DAL.Vendor mVendor = new DAL.Vendor();
            return mVendor.Add(Vendor_Name, Vendor_Support_Phone, Vendor_Support_Email, Vendor_Notes);
        }

        public bool Update(string Vendor_Name, string Vendor_Support_Phone, string Vendor_Support_Email, string Vendor_Notes, string Vendor_ID)
        {
            DAL.Vendor mVendor = new DAL.Vendor();
            return mVendor.Update(Vendor_Name, Vendor_Support_Phone, Vendor_Support_Email, Vendor_Notes, Vendor_ID);
        }

        public List<VO.Vendor> GetVendor()
        {
            List<VO.Vendor> mList = new List<VO.Vendor>();
            DAL.Vendor mVendor = new DAL.Vendor();
            DataTable mDataTable = mVendor.GetVendor();

            foreach (DataRow dr in mDataTable.Rows)
            {
                VO.Vendor voVendor = new VO.Vendor();
                voVendor.Vendor_ID = Convert.ToInt32(dr["Vendor_ID"].ToString());
                voVendor.Vendor_Name = dr["Vendor_Name"].ToString();
                voVendor.Vendor_Notes = dr["Vendor_Notes"].ToString();
                voVendor.Vendor_Support_Email = dr["Vendor_Support_Email"].ToString();
                voVendor.Vendor_Support_Phone = dr["Vendor_Support_Phone"].ToString();

                mList.Add(voVendor);
            }

            return mList;
        }
    }
}
